<template>
  <div class="list">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="ID">
      </el-table-column>
      <el-table-column prop="account" label="交易账号">
      </el-table-column>
      <el-table-column prop="name" label="账户名称">
      </el-table-column>
      <!-- <el-table-column prop="mode" label="账户类型">
        <template slot-scop="{row,index}">
            <span>模拟账户</span>
        </template>
      </el-table-column> -->
    </el-table>
    <el-pagination background layout="prev, pager, next" :total="total" :page-size="size" @prev-click="prev()"
      @next-click="next()" @current-change="currentchange" style="margin-top: 20px;">
    </el-pagination>
  </div>
</template>

<script>
  import {
    ajaxPost
  } from "@/api/ajax"
  export default {
    name: "list",
    data() {
      return {
        tableData: [],
        page: 1,
        size: 15,
        total: 0,
        current_page: 1,
      };
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        let data = {
          page: this.page,
          size: this.size,
        };
        ajaxPost('trade/list', data).then(res => {
          if (res.code == 0) {
            this.tableData = res.data.data;
            this.total = res.data.total;
            this.current_page = res.data.current_page;
          }
        })
      },
      prev() {
        this.page -= 1;
        this.getList();
      },
      next() {
        this.page += 1;
        this.getList();
      },
      currentchange(value) {
        this.page = value;
        this.getList();
      },
      editStatus(val) {
        ajaxPost("broker/editStatus", val).then(res => {
          if (res.code == 0) {
            this.getList();
          }
        })
      },
    },
  }
</script>

<style>
  .list {
    padding: 20px;
    box-sizing: border-box;

    .search-input {
      width: 150px;
    }

    .list-page {
      margin-top: 20px;
    }
  }
</style>
